﻿package mortal.game.view.lookPlayerInfo
{
    import Message.Game.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.lookPlayerInfo.view.*;
    import mortal.game.view.palyer.data.*;
    import mortal.game.view.palyer.view.*;
    import mortal.mvc.core.*;

    public class LookPlayerSystemModule extends BaseWindow
    {
        private var _tabData:Array;
        public var slookPlayerInfo:SLookPlayerInfo;
        private var _lookType:int;
        private var _tabBars:GTileList;
        private var _currentPanel:GSprite;

        public function LookPlayerSystemModule()
        {
            this._tabData = new Array();
            super(LayerManager.windowLayer3D);
            setSize(766, 580);
            this.title = Language.getString(35343);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._tabBars = UIFactory.tileList(-79, 50, 80, 540, this);
            this._tabBars.columnWidth = 92;
            this._tabBars.rowHeight = 43;
            this._tabBars.horizontalGap = 3;
            this._tabBars.verticalGap = 0;
            this._tabBars.setStyle("cellRenderer", PlayerTabCellRender);
            this._tabBars.configEventListener(Event.CHANGE, this.onTabBarChangeHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            if (this._currentPanel)
            {
                this._currentPanel.dispose(param1);
                this._currentPanel = null;
            }
            this._tabBars.dispose(param1);
            this._tabBars = null;
            this.slookPlayerInfo = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function updateTabData() : void
        {
            var _loc_3:PlayerTabData = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:* = this.slookPlayerInfo.miniPlayer.level;
            if (_loc_2 >= 0)
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_Role;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(1))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_Mount;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(2))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_Pet;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(67))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_Wing;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(66))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_Clothes;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(68))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_Artifact;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(69))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_FightSoul;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(70))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_FightMethod;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameDefConfig.instance.getSystemOpenLevel(71))
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_DragonSoul;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameConst.HolyBookOpenLevel)
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_HolyBook;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameConst.WarShieldOpenLevel)
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_WarShield;
                _loc_1.addItem(_loc_3);
            }
            if (_loc_2 >= GameConst.MonsterSoulOpenLevel)
            {
                _loc_3 = new PlayerTabData();
                _loc_3.tabType = PlayerConst.TabType_MonsterSoul;
                _loc_1.addItem(_loc_3);
            }
            this._tabBars.dataProvider = _loc_1;
            return;
        }// end function

        private function onTabBarChangeHandler(event:Event = null) : void
        {
            var _loc_4:GSprite = null;
            var _loc_2:* = this._tabBars.selectedItem as PlayerTabData;
            var _loc_3:* = _loc_2.tabType;
            if (this._currentPanel)
            {
                this._currentPanel.dispose();
                this._currentPanel = null;
            }
            if (_loc_3 == PlayerConst.TabType_Role)
            {
                _loc_4 = UICompomentPool.getUICompoment(LookPlayerInfoPanel, this);
                (_loc_4 as LookPlayerInfoPanel).window = this;
                (_loc_4 as LookPlayerInfoPanel).data = this.slookPlayerInfo;
                this._lookType = ELookUpType._ELookUpTypePlayer;
                this._currentPanel = _loc_4;
            }
            else
            {
                if (_loc_3 == PlayerConst.TabType_Mount)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeMount;
                }
                else if (_loc_3 == PlayerConst.TabType_Pet)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypePet;
                }
                else if (_loc_3 == PlayerConst.TabType_Clothes)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeFashion;
                }
                else if (_loc_3 == PlayerConst.TabType_Wing)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeWings;
                }
                else if (_loc_3 == PlayerConst.TabType_Artifact)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeWeapon;
                }
                else if (_loc_3 == PlayerConst.TabType_FightSoul)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeFightSoul;
                }
                else if (_loc_3 == PlayerConst.TabType_FightMethod)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeFightMethod;
                }
                else if (_loc_3 == PlayerConst.TabType_DragonSoul)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeDragonSoul;
                }
                else if (_loc_3 == PlayerConst.TabType_HolyBook)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeHolyBook;
                }
                else if (_loc_3 == PlayerConst.TabType_WarShield)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeWarShield;
                }
                else if (_loc_3 == PlayerConst.TabType_MonsterSoul)
                {
                    _loc_4 = UICompomentPool.getUICompoment(LookOtherSystemBaseWin, this);
                    this._lookType = ELookUpType._ELookUpTypeMonsterSoul;
                }
                (_loc_4 as LookOtherSystemBaseWin).window = this;
                this._currentPanel = _loc_4;
                Dispatcher.dispatchEvent(new DataEvent(EventName.LookPlayerInfoByType, {type:this._lookType, id:this.slookPlayerInfo.miniPlayer.entityId}));
            }
            if (this._currentPanel)
            {
                this.addChild(this._currentPanel);
            }
            return;
        }// end function

        public function updatePlayerInfo(param1:SLookPlayerInfo) : void
        {
            this.slookPlayerInfo = param1;
            this.updateTabData();
            this._tabBars.selectedIndex = 0;
            this.onTabBarChangeHandler();
            return;
        }// end function

        public function updateOtherSysteamInfo(param1:SLookPlayerMountInfo) : void
        {
            if (this._currentPanel is LookOtherSystemBaseWin)
            {
                (this._currentPanel as LookOtherSystemBaseWin).setLookInfo(param1, this.slookPlayerInfo, this._lookType);
            }
            return;
        }// end function

        override public function hide() : void
        {
            super.hide();
            Dispatcher.dispatchEvent(new DataEvent(EventName.LookPlayerModuleClosed, this));
            return;
        }// end function

    }
}
